﻿using APP.HELPER.Data.Helper;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;

namespace HRM.CORE
{
    public class HRM_DISCIPLINE
    {
        private DateTime m_Date;
        private DateTime m_DateOccurred;
        private string m_DecideNumber;
        private string m_Description;
        private string m_DisciplineCode;
        private string m_DisciplineName;
        private string m_FilePath;
        private string m_Form;
        private string m_Location;
        private string m_Notes;
        private string m_Person;
        private string m_Reason;
        private bool m_Settlement;
        private int m_Status;
        private bool m_Violations;
        private string m_Witnesses;

        public HRM_DISCIPLINE()
        {
            this.m_DisciplineCode = "";
            this.m_DisciplineName = "";
            this.m_DateOccurred = DateTime.Now;
            this.m_Location = "";
            this.m_Description = "";
            this.m_Witnesses = "";
            this.m_Violations = true;
            this.m_Notes = "";
            this.m_Form = "";
            this.m_Settlement = true;
            this.m_Reason = "";
            this.m_Date = DateTime.Now;
            this.m_DecideNumber = "";
            this.m_Person = "";
            this.m_FilePath = "";
            this.m_Status = 0;
        }

        public HRM_DISCIPLINE(string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            this.m_DisciplineCode = DisciplineCode;
            this.m_DisciplineName = DisciplineName;
            this.m_DateOccurred = DateOccurred;
            this.m_Location = Location;
            this.m_Description = Description;
            this.m_Witnesses = Witnesses;
            this.m_Violations = Violations;
            this.m_Notes = Notes;
            this.m_Form = Form;
            this.m_Settlement = Settlement;
            this.m_Reason = Reason;
            this.m_Date = Date;
            this.m_DecideNumber = DecideNumber;
            this.m_Person = Person;
            this.m_FilePath = FilePath;
            this.m_Status = Status;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { this.m_DisciplineCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_DISCIPLINE_Delete", myParams, myValues);
        }

        public string Delete(string DisciplineCode)
        {
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_DISCIPLINE_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string DisciplineCode)
        {
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_DISCIPLINE_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string DisciplineCode)
        {
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_DISCIPLINE_Delete", myParams, myValues);
        }

        public bool Exist(string DisciplineCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string DisciplineCode)
        {
            string str = "";
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DisciplineCode = Convert.ToString(reader["DisciplineCode"]);
                    this.m_DisciplineName = Convert.ToString(reader["DisciplineName"]);
                    this.m_DateOccurred = Convert.ToDateTime(reader["DateOccurred"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Witnesses = Convert.ToString(reader["Witnesses"]);
                    this.m_Violations = Convert.ToBoolean(reader["Violations"]);
                    this.m_Notes = Convert.ToString(reader["Notes"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Settlement = Convert.ToBoolean(reader["Settlement"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string DisciplineCode)
        {
            string str = "";
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DisciplineCode = Convert.ToString(reader["DisciplineCode"]);
                    this.m_DisciplineName = Convert.ToString(reader["DisciplineName"]);
                    this.m_DateOccurred = Convert.ToDateTime(reader["DateOccurred"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Witnesses = Convert.ToString(reader["Witnesses"]);
                    this.m_Violations = Convert.ToBoolean(reader["Violations"]);
                    this.m_Notes = Convert.ToString(reader["Notes"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Settlement = Convert.ToBoolean(reader["Settlement"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string DisciplineCode)
        {
            string str = "";
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DisciplineCode = Convert.ToString(reader["DisciplineCode"]);
                    this.m_DisciplineName = Convert.ToString(reader["DisciplineName"]);
                    this.m_DateOccurred = Convert.ToDateTime(reader["DateOccurred"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Witnesses = Convert.ToString(reader["Witnesses"]);
                    this.m_Violations = Convert.ToBoolean(reader["Violations"]);
                    this.m_Notes = Convert.ToString(reader["Notes"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Settlement = Convert.ToBoolean(reader["Settlement"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_DISCIPLINE_GetList");
        }

        public DataTable GetListByDate(DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_DISCIPLINE_GetListByDate", myParams, myValues);
        }

        public DataTable GetListByID(string DisciplineCode)
        {
            string[] myParams = new string[] { "@DisciplineCode" };
            object[] myValues = new object[] { DisciplineCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_DISCIPLINE_GetListByID", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { this.m_DisciplineCode, this.m_DisciplineName, this.m_DateOccurred, this.m_Location, this.m_Description, this.m_Witnesses, this.m_Violations, this.m_Notes, this.m_Form, this.m_Settlement, this.m_Reason, this.m_Date, this.m_DecideNumber, this.m_Person, this.m_FilePath, this.m_Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { this.m_DisciplineCode, this.m_DisciplineName, this.m_DateOccurred, this.m_Location, this.m_Description, this.m_Witnesses, this.m_Violations, this.m_Notes, this.m_Form, this.m_Settlement, this.m_Reason, this.m_Date, this.m_DecideNumber, this.m_Person, this.m_FilePath, this.m_Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { DisciplineCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { DisciplineCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { DisciplineCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_DISCIPLINE_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_DISCIPLINE", "DisciplineCode", "KL");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { this.m_DisciplineCode, this.m_DisciplineName, this.m_DateOccurred, this.m_Location, this.m_Description, this.m_Witnesses, this.m_Violations, this.m_Notes, this.m_Form, this.m_Settlement, this.m_Reason, this.m_Date, this.m_DecideNumber, this.m_Person, this.m_FilePath, this.m_Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_DISCIPLINE_Update", myParams, myValues);
        }

        public string Update(string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { DisciplineCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_DISCIPLINE_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { DisciplineCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_DISCIPLINE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string DisciplineCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath, int Status)
        {
            string[] myParams = new string[] { "@DisciplineCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath", "@Status" };
            object[] myValues = new object[] { DisciplineCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_DISCIPLINE_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("Date")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [DisplayName("DateOccurred"), Category("Column")]
        public DateTime DateOccurred
        {
            get
            {
                return this.m_DateOccurred;
            }
            set
            {
                this.m_DateOccurred = value;
            }
        }

        [Category("Column"), DisplayName("DecideNumber")]
        public string DecideNumber
        {
            get
            {
                return this.m_DecideNumber;
            }
            set
            {
                this.m_DecideNumber = value;
            }
        }

        [Category("Column"), DisplayName("Description")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Primary Key"), DisplayName("DisciplineCode")]
        public string DisciplineCode
        {
            get
            {
                return this.m_DisciplineCode;
            }
            set
            {
                this.m_DisciplineCode = value;
            }
        }

        [Category("Column"), DisplayName("DisciplineName")]
        public string DisciplineName
        {
            get
            {
                return this.m_DisciplineName;
            }
            set
            {
                this.m_DisciplineName = value;
            }
        }

        [DisplayName("FilePath"), Category("Column")]
        public string FilePath
        {
            get
            {
                return this.m_FilePath;
            }
            set
            {
                this.m_FilePath = value;
            }
        }

        [Category("Column"), DisplayName("Form")]
        public string Form
        {
            get
            {
                return this.m_Form;
            }
            set
            {
                this.m_Form = value;
            }
        }

        [DisplayName("Location"), Category("Column")]
        public string Location
        {
            get
            {
                return this.m_Location;
            }
            set
            {
                this.m_Location = value;
            }
        }

        [Category("Column"), DisplayName("Notes")]
        public string Notes
        {
            get
            {
                return this.m_Notes;
            }
            set
            {
                this.m_Notes = value;
            }
        }

        [Category("Column"), DisplayName("Person")]
        public string Person
        {
            get
            {
                return this.m_Person;
            }
            set
            {
                this.m_Person = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_DISCIPLINE";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Reason")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }

        [DisplayName("Settlement"), Category("Column")]
        public bool Settlement
        {
            get
            {
                return this.m_Settlement;
            }
            set
            {
                this.m_Settlement = value;
            }
        }

        [DisplayName("Status"), Category("Column")]
        public int Status
        {
            get
            {
                return this.m_Status;
            }
            set
            {
                this.m_Status = value;
            }
        }

        [DisplayName("Violations"), Category("Column")]
        public bool Violations
        {
            get
            {
                return this.m_Violations;
            }
            set
            {
                this.m_Violations = value;
            }
        }

        [DisplayName("Witnesses"), Category("Column")]
        public string Witnesses
        {
            get
            {
                return this.m_Witnesses;
            }
            set
            {
                this.m_Witnesses = value;
            }
        }
    }
}

